/**
 * Mobile Vip qq.com
 * @author Levin
 * @version 1.0
 */
JF.M("base",(function(){
	var p={},pub={};
	/* private methods
	++++++++++++++++++*/
	//导航模块
	p.nav={
		init:function(){
			var me=this;
			//首页导航
			$("#nav a").bind("tap",function(){
				var $i=$(this);
				
				JF.base.log(JF.jqmExt.data().isPageTransitioning);
				JF.base.log("#nav a tap");

				if($i.hasClass(p.opts.clCur)||JF.jqmExt.data().isPageTransitioning) return false;

				$("#nav a").removeClass(p.opts.clCur);
				$i.addClass(p.opts.clCur);

			});

		}
	};

	/* public methods
	++++++++++++++++++*/
	pub.init=function(opts){

		document.addEventListener('touchmove',function(e){e.preventDefault();},false);

		p.opts=$.extend({
			clCur:'current'
		},opts||{});

		$('.page').live('pagecreate',function(event){
		   //logic on pagecreate
		});

		//p.loader.init();
		
	};
	/**
	 * 页面加载完毕后执行的逻辑
	 */
	pub.onLoad=function(){
		//p.nav.init();
	};

	/**
	 * preJqmInit,override the default jquery.mobile configurations
	 */
	pub.preJqmInit=function(){
		$(document).bind("mobileinit", function(){
			//blabla
		});

	};
	 //TODO:rename to setTitle
	pub.log=function(txt,transition){
		var $t=$("#title_inner"),$wrap=$("#title");
		if(!txt){
			$t.html("");
			$wrap.hide();
			return;
		};
		$wrap.animationComplete(function(){
			$(this).removeClass("slide in out");
		});
		$t.html(JF.Tail(txt,14));
		$wrap.show();
		if(transition!=='none'){
			$wrap.addClass("slide in");
		};
		$t=$wrap=null;
	};
	
	pub.onScrollEnd=function(data){
		data.target.next(".indicator").find("li").removeClass("active").eq(this.currPageX).addClass("active");
	};

	return pub;
})());